//
//  WBHomeViewController.swift
//  WSWeibo
//
//  Created by guojianfeng on 2017/7/13.
//  Copyright © 2017年 guojianfeng. All rights reserved.
//

import UIKit

fileprivate let cellId = "WBHomeViewControllerCellid"

class WBHomeViewController: WBBaseViewController {
    fileprivate lazy var lisetViewModel = WBStatusListViewModel()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    override func loadData() {
        lisetViewModel.loadStatus(pullup: self.isPullUp) { (isSuccess) in
            self.endRefresh()
            self.isPullUp = false
            self.tableView?.reloadData()
        }
    }

    @objc fileprivate func showFriends(){
        let vc = WBTestViewController()
        vc.hidesBottomBarWhenPushed  = true
        navigationController?.pushViewController(vc, animated: true)
    }
}

extension WBHomeViewController{
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return lisetViewModel.statusList.count
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath)
        cell.textLabel?.text = lisetViewModel.statusList[indexPath.row].text
        return cell
    }
}

extension WBHomeViewController{
    override func setupTableView() {
        super.setupTableView()
        navItem.leftBarButtonItem = UIBarButtonItem.init(title: "好友", target: self, action: #selector(showFriends))
        tableView?.register(UITableViewCell.self, forCellReuseIdentifier: cellId)
    }
}
